<template>
  <div>
<h2>注册页面</h2>
  </div>
  <table border="1">
    <tr>
      <td>用户名</td>
      <td>
        <input type="text" v-model="state.name">
      </td>
    </tr>
    <tr>
      <td>密码</td>
      <td>
        <input type="password" v-model="state.pwd">
      </td>
    </tr>
    <tr>
      <td></td>
      <td>
        <input type="button" value="注册" @click="add">
        <input type="button" value="新增会员" @click="jump">
      </td>
    </tr>
  </table>
</template>

<script setup lang="ts">
import axios from 'axios';
import{reactive,toRefs,onMounted} from'vue'
import { useRoute,useRouter  } from 'vue-router';
let route=useRoute();
let router=useRouter();
let data=reactive({
  state:{
   name: '',
  pwd: ''
  }
})
let{state}=toRefs(data)
function add()
{
  let obj={
    "name": state.value.name,
  "pwd": state.value.pwd
  }
  if(state.value.name=="")
  {
    alert("用户名不能为空")
    return;
  }
  if(state.value.pwd=="")
  {
    alert("密码不能为空")
    return;
  }
  if(state.value.pwd.length<6)
  {
    alert("密码必须大于6位数")
    return;
  }
  axios({
    url:'/api/Member/Zhuce',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.data==1)
  {
    alert("注册成功")
   
  }
  }).catch(err=>{

  })
}
function jump()
{
  router.push("../add")
}
</script>

<style scoped>

</style>